﻿//创建时间: 2010-12-15
//创建作者: 李 城
//功能说明: cms外部页面访问基类  广告访问页
//最后修改: 2010-12-15
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Web;
using TRPOP.Common;
using TRPOP.Config;

namespace TRPOP.CMS.Web.ExtraBus
{
    /// <summary>
    /// 广告访问页
    /// </summary>
    public class Page_Load_AdContent : BasePage
    {

        protected override void OnPreInit(EventArgs e)
        {
            if (!IsPostBack && ExecutePageURLCahche())
            {
                return;
            }
            base.OnPreInit(e);
        }

        protected override void OnInit(EventArgs e)
        {
            string strRecommentSubmitUrl = SYSConfig.AdvertisementDynamicAccessUrl;
            string strDynamicPageName =
                (base.mCurrentUrl.ToLower().Contains(strRecommentSubmitUrl.ToLower().Trim())) ? "AdvertisementDynamicAccessUrl" : "";
            if (strDynamicPageName == "AdvertisementDynamicAccessUrl")
                AD_Content();
            else
                Base_Config.NotFound(base.Page, "CMS后台配置的页面地址和访问的页面不一致(广告)");
            //base.OnInit(e);
        }

        /// <summary>
        /// 广告访问页
        /// </summary>
        public void AD_Content()
        {
            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            int intIndexID = RequestHelper.RequestInt("id");
            AdvscontentManage oAdvscontentManage = new AdvscontentManage();
            AdvscontentInfo oAdvscontentInfo = oAdvscontentManage.GetInfoById(intIndexID);
            if (oAdvscontentInfo == null)
            {
                Response.End();
                return;
            }
            oAdvscontentManage.UpdateAfterSave(oAdvscontentInfo, false);
            oAdvscontentManage.UpdateIMGUrl(oAdvscontentInfo);
            string strHtml = oAdvscontentInfo.Detial;
            switch (RequestHelper.RequestString("type"))
            {
                case "content":
                    //保持strHtml不变即可
                    break;
                default:
                    TRPOP.Common.JsUtil.JSDocWriteHTML(ref strHtml);
                    break;
            }
            if (base.mBlnEnableCache)
                base.mICache.Save(base.mCacheKey, strHtml, BasePage.mCacheSeconds);
            Response.Write(strHtml);
        }
    }
}